<button class="btn btn-success btn-xs" data-toggle="modal" data-target="#customerEdit{{ $id }}">编辑</button>

<div class="modal fade" id="customerEdit{{ $id }}" tabindex="-1" role="dialog" aria-labelledby="customerEdit" aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">&times;</button>
                <h4 class="modal-title" id="myModalLabel">编辑客户</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">客户名</label>
                    <input type="text" name="customerName{{ $id }}" value="{{ $data->customer_name }}" class="form-control" placeholder="请输入客户名">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">年龄</label>
                    <input type="number" name="age{{ $id }}" maxlength="2" value="{{ $data->age }}" class="form-control" placeholder="请输入年龄">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">性别</label>
                    <select class="form-select form-control" name="customerGender{{ $id }}">
                        <option value="0" {{ (int)$data['customer_gender']?'':'selected' }}>女</option>
                        <option value="1"  {{ (int)$data['customer_gender']?'selected':'' }}>男</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">手机号</label>
                    <input type="text" name="customerMobile{{ $id }}" maxlength="11" value="{{ $data->customer_mobile }}" class="form-control" placeholder="请输入手机号">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">微信</label>
                    <input type="text" name="customerWechat{{ $id }}" value="{{ $data->customer_wechat }}" class="form-control" placeholder="请输入微信">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">信息来源</label>
                    <select class="form-select form-control" name="informationResources{{ $id }}">
                        @foreach(__('customer.informationResourcesArr') as $k => $v)
                            @if($data['information_resources'] === $k)
                                <option value="{{ $k }}" selected>{{ $v }}</option>
                            @else
                                <option value="{{ $k }}">{{ $v }}</option>
                            @endif
                        @endforeach
                    </select>
                </div>
{{--                <div class="mb-3">--}}
{{--                    <label for="exampleFormControlInput1" class="form-label">状态</label>--}}
{{--                    <select class="form-select form-control" name="customerStatus{{ $id }}">--}}
{{--                        @foreach(__('customer.customerStatusArr') as $k1 => $v1)--}}
{{--                            @if($data['information_resources'] === $k1)--}}
{{--                                <option value="{{ $k1 }}" selected>{{ $v1 }}</option>--}}
{{--                            @else--}}
{{--                                <option value="{{ $k1 }}">{{ $v1 }}</option>--}}
{{--                            @endif--}}
{{--                        @endforeach--}}
{{--                    </select>--}}
{{--                </div>--}}
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">地址</label>
                    <input type="text" name="customerAddress{{ $id }}" value="{{ $data->customer_address }}" class="form-control" placeholder="请输入地址">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">备注</label>
                    <textarea name="remark{{ $id }}" class="form-control" value="{{ $data->remark }}" placeholder="请输入备注"></textarea>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">业务员</label>
                    <input type="text" class="form-control" disabled value="{{ auth()->user()->name }}">
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="customerEdit({{ $id }})">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function customerEdit(id)
    {
        ajaxPostFunc('/admin/ajax/customerEdit', {
            id: id,
            customer_name: $("input[name='customerName"+id+"']").val(),
            age: $("input[name='age"+id+"']").val(),
            customer_gender: $("select[name='customerGender"+id+"']").val(),
            customer_mobile: $("input[name='customerMobile"+id+"']").val(),
            customer_wechat: $("input[name='customerWechat"+id+"']").val(),
            customer_qq: $("input[name='customerQq"+id+"']").val(),
            education: $("select[name='education"+id+"']").val(),
            information_resources: $("select[name='informationResources"+id+"']").val(),
            // customer_status: $("select[name='customerStatus"+id+"']").val(),
            customer_address: $("input[name='customerAddress"+id+"']").val(),
            remark: $("textarea[name='remark"+id+"']").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
